#include "athread.h"

#include <QDebug>

void AThread::run()
{
    DelayLoopTimer = new QTimer();
    DelayLoop = new QEventLoop;

    connect(&bThread, &BThread::finished, DelayLoop, &QEventLoop::quit);
    connect(&bThread, &BThread::finished, &bThread, &BThread::deleteLater);
    connect(DelayLoopTimer, &QTimer::timeout, DelayLoop, &QEventLoop::quit );

    bThread.start();

    bThread.setRunFlag();
    DelayLoopTimer->setSingleShot(true);
    DelayLoopTimer->start(1000);
    qDebug() << "Wait for timer";
    DelayLoop->exec();
    qDebug() << "Wait for timer end ";

    if(DelayLoopTimer->isActive())
    {
        qDebug("wait succeed ");
        DelayLoopTimer->stop();
    }
    else
    {
        qDebug("wait failed");
    }
}
